package demo6Lianxi20250331;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Demo {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("demo6Lianxi20250331");
        /*
        * 在Spring容器内部,被管理的类默认为单例模式。
        * 因此无论向Spring容器获取一个类多少次实例,返回的始终为同一个对象
        * */
        Person p1 = context.getBean(Person.class);
        System.out.println(p1);
        Person p2 = context.getBean(Person.class);
        System.out.println(p2);
        Person p3 = context.getBean(Person.class);
        System.out.println(p3);
    }
}
